package com.erp.erp_servers.ProductLog.imp;

import com.erp.erp_dao.ProductLog.IProductLogDAO;
import com.erp.erp_entitys.ProductLog.ProductLogEntity;
import com.erp.erp_entitys.ProductLog.ProductLogExample;
import com.erp.erp_servers.ProductLog.IProductLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ImpProductLogService implements IProductLogService {
    @Autowired
    IProductLogDAO productLogDAO;
    @Override
    public long countByExample(ProductLogExample example) {
        return productLogDAO.countByExample(example);
    }

    @Override
    public int deleteByExample(ProductLogExample example) {
        return productLogDAO.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return productLogDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(ProductLogEntity record) {
        return productLogDAO.insert(record);
    }

    @Override
    public int insertSelective(ProductLogEntity record) {
        return productLogDAO.insertSelective(record);
    }

    @Override
    public List<ProductLogEntity> selectByExample(ProductLogExample example) {
        return productLogDAO.selectByExample(example);
    }

    @Override
    public ProductLogEntity selectByPrimaryKey(Integer id) {
        return productLogDAO.selectByPrimaryKey(id);
    }

    @Override
    public int updateByExampleSelective(ProductLogEntity record, ProductLogExample example) {
        return productLogDAO.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByExample(ProductLogEntity record, ProductLogExample example) {
        return productLogDAO.updateByExample(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(ProductLogEntity record) {
        return productLogDAO.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(ProductLogEntity record) {
        return productLogDAO.updateByPrimaryKey(record);
    }

    @Override
    public void savelog(String productCode, String type, String content,String username,String usercode) {
       // UserEntity user = (UserEntity)this.getBean("user");
        ProductLogEntity record=new ProductLogEntity();
        record.setType(type);
        record.setOptioner(username+":"+usercode);
        record.setContent(content);
        record.setProductCode(productCode);
        record.setTime(new Date());
        productLogDAO.insert(record);
    }
}
